import Mock from 'mockjs'
import {getQueryParameters} from "../util/util"

//对外输出对应的数据接口
export  default ()=>{

    Mock.mock(/\/student\/studentPagedList/,'get',(params)=>{
        const paramObj=getQueryParameters(params)

        const classList=['计算机一班','软件工程二班','网络工程三班','审计一班','护理七班','电子商务一班','信管二班']
        const sex = ['男','女']
        const No = ['18434010103','18434010104','18434010105','18434010106','18434010107','18434010108','17434010103',
            '17434010104','17434010105','17434010106','17434010107','17434010108','18434010203','18434010204','18434010205','18434010206','18434010207','18434010208']

        const studentList=[]

        const totalCount=500

        const pageIndex=parseInt(paramObj.pageIndex)
        const pageSize=parseInt(paramObj.pageSize)
        const totalPage=Math.ceil(totalCount/pageSize)//向上取整

        const startNo=(pageIndex-1)*pageSize+1//计算开始Id
        const endNo=pageIndex<totalPage?pageIndex*pageSize:totalCount

        for(let i=startNo;i<=endNo;i++){
            studentList.push(Mock.mock({
                key:i,
                studentName:Mock.mock('@cname'),
                studentNo:Mock.Random.pick(No),
                gender:Mock.Random.pick(sex),
                className:Mock.Random.pick(classList)
            }))
        }

        return {
            total:totalCount,
            data:studentList
        }

    })
}
